package Review;


public class Test16 {

	public static void main(String[] args) {
		ListNode p1 = new ListNode(1);
		ListNode p2 = new ListNode(2);
		ListNode p3 = new ListNode(3);
		ListNode p4 = new ListNode(4);
		p1.next=p2;
		p2.next=null;
		p3.next=p4;
		p4.next=null;
		System.out.println(reverseList(p1).value);
	}
    public static ListNode reverseList(ListNode head){
    	if(head==null){
    		return null;
    	}
    	ListNode pre=head;
    	ListNode p=head.next;
    	head.next=null;
    	while(p!=null){
    		ListNode nxt=p.next;
    		p.next=pre;
    		pre=p;
    		p=nxt;
    		
    	}
    	return pre;
    	
    }
    
}
